package org.goyo.main.domain.entity.sale;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import org.goyo.main.domain.entity.BaseEntryObject;
import org.goyo.main.domain.entity.base.BaseUnitMeasure;
import org.goyo.main.domain.entity.base.Material;
import org.goyo.main.domain.entity.base.MaterialEntry;
/**
 * 销售订单分录
 * 
 * @author chenchuan
 * 2014年11月12日
 */
@Entity
public class SaleOrderEntry  extends BaseEntryObject implements Serializable {

	private static final long serialVersionUID = 1L;
	
	/**
	 * 商品
	 */
	@ManyToOne
	@JoinColumn(name="materialId")
	private Material material;
	/**
	 * 商品名称	
	 */
	@Column
	private String materialName;
	/**
	 * 商品规格型号	
	 */
	@Column
	private String materialStandard;
	/**
	 * 计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="jilUnitId")
	private BaseUnitMeasure jilUnit;
	/**
	 * 销售数量	
	 */
	@Column
	private double saleQty = 0;
	
	/**
	 * 辅助计量单位	
	 */
	@ManyToOne
	@JoinColumn(name="fjilUnitId")
	private MaterialEntry fjilUnit;
	
	/**
     * 辅助换算率
     */
	@Column
    private String conversionRate;
	/**
	 * 辅助数量	
	 */
	@Column
	private double fsaleQty = 0;
	/**
	 * 含税单价	
	 */
	@Column
	private BigDecimal taxPrice = BigDecimal.ZERO;
	/**
	 * 销项税率%	
	 */
	@Column
	private BigDecimal incomeRate = BigDecimal.ZERO;
	/**
	 * 单价	
	 */
	@Column
	private BigDecimal price = BigDecimal.ZERO;
	/**
	 * 折扣率	
	 */
	@Column
	private BigDecimal discountRate = BigDecimal.ZERO;
	/**
	 * 折扣额	
	 */
	@Column
	private BigDecimal discountLimit = BigDecimal.ZERO;
	/**
	 * 税额	
	 */
	@Column
	private BigDecimal taxLimit = BigDecimal.ZERO;
	/**
	 * 不含税额	
	 */
	@Column
	private BigDecimal notTaxLimit = BigDecimal.ZERO;
	/**
	 * 价税合计	
	 */
	@Column
	private BigDecimal taxAmount = BigDecimal.ZERO;
	/**
	 * 累计发运数量	
	 */
	@Column
	private double sumDispQty = 0;
	/**
	 * 累计出库数量	
	 */
	@Column
	private double sumOutQty = 0;
	/**
	 * 累计退库数量	
	 */
	@Column
	private double sumQuitQty = 0;
	/**
	 * 累计收款金额	
	 */
	@Column
	private BigDecimal sumReceiptAmount = BigDecimal.ZERO;
	
	@ManyToOne(cascade={CascadeType.MERGE})
	@JoinColumn(name="parentId")
	private SaleOrder saleOrder;

	public String getMaterialName() {
		return materialName;
	}
	public void setMaterialName(String materialName) {
		this.materialName = materialName;
	}
	public String getMaterialStandard() {
		return materialStandard;
	}
	public void setMaterialStandard(String materialStandard) {
		this.materialStandard = materialStandard;
	}

	public Material getMaterial() {
		return material;
	}
	public void setMaterial(Material material) {
		if(material != null &&("".equals(material.getUuid()) || material.getUuid()==null))
			this.material = null;
		else
			this.material = material;	
	}
	public BaseUnitMeasure getJilUnit() {
		return jilUnit;
	}
	public void setJilUnit(BaseUnitMeasure jilUnit) {
		if(jilUnit != null &&("".equals(jilUnit.getUuid()) || jilUnit.getUuid()==null))
			this.jilUnit = null;
		else
			this.jilUnit = jilUnit;	
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public SaleOrder getSaleOrder() {
		return saleOrder;
	}
	public void setSaleOrder(SaleOrder saleOrder) {
		this.saleOrder = saleOrder;
	}
	public double getSaleQty() {
		return saleQty;
	}
	public void setSaleQty(double saleQty) {
		this.saleQty = saleQty;
	}
	public BigDecimal getTaxPrice() {
		return taxPrice;
	}
	public void setTaxPrice(BigDecimal taxPrice) {
		this.taxPrice = taxPrice;
	}
	public BigDecimal getIncomeRate() {
		return incomeRate;
	}
	public void setIncomeRate(BigDecimal incomeRate) {
		this.incomeRate = incomeRate;
	}
	public BigDecimal getPrice() {
		return price;
	}
	public void setPrice(BigDecimal price) {
		this.price = price;
	}
	public BigDecimal getDiscountRate() {
		return discountRate;
	}
	public void setDiscountRate(BigDecimal discountRate) {
		this.discountRate = discountRate;
	}
	public BigDecimal getDiscountLimit() {
		return discountLimit;
	}
	public void setDiscountLimit(BigDecimal discountLimit) {
		this.discountLimit = discountLimit;
	}
	public BigDecimal getTaxLimit() {
		return taxLimit;
	}
	public void setTaxLimit(BigDecimal taxLimit) {
		this.taxLimit = taxLimit;
	}
	public BigDecimal getNotTaxLimit() {
		return notTaxLimit;
	}
	public void setNotTaxLimit(BigDecimal notTaxLimit) {
		this.notTaxLimit = notTaxLimit;
	}
	public BigDecimal getTaxAmount() {
		return taxAmount;
	}
	public void setTaxAmount(BigDecimal taxAmount) {
		this.taxAmount = taxAmount;
	}
	public double getSumDispQty() {
		return sumDispQty;
	}
	public void setSumDispQty(double sumDispQty) {
		this.sumDispQty = sumDispQty;
	}
	public double getSumOutQty() {
		return sumOutQty;
	}
	public void setSumOutQty(double sumOutQty) {
		this.sumOutQty = sumOutQty;
	}
	public double getSumQuitQty() {
		return sumQuitQty;
	}
	public void setSumQuitQty(double sumQuitQty) {
		this.sumQuitQty = sumQuitQty;
	}
	public BigDecimal getSumReceiptAmount() {
		return sumReceiptAmount;
	}
	public void setSumReceiptAmount(BigDecimal sumReceiptAmount) {
		this.sumReceiptAmount = sumReceiptAmount;
	}

	public MaterialEntry getFjilUnit() {
    return fjilUnit;
  }
  public void setFjilUnit(MaterialEntry fjilUnit) {
    if(fjilUnit != null &&("".equals(fjilUnit.getUuid()) || fjilUnit.getUuid()==null))
      this.fjilUnit = null;
  else
      this.fjilUnit = fjilUnit; 
  }
  public double getFsaleQty() {
		return fsaleQty;
	}
	public void setFsaleQty(double fsaleQty) {
		this.fsaleQty = fsaleQty;
	}
  public String getConversionRate() {
    return conversionRate;
  }
  public void setConversionRate(String conversionRate) {
    this.conversionRate = conversionRate;
  }
	
	
}
